package gui.archerDbEditor;


import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JTable;

public class ArcherDbEditorMouseListener implements MouseListener {
	ArcherDbEditor window;

	public ArcherDbEditorMouseListener(ArcherDbEditor archerDbEditor) {
		this.window = archerDbEditor;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		if (e.getSource() instanceof JTable) {
			try {
				this.window.controller.filloutForm();
				/** in case of changing checkbox-value, save immediately */
				if ((this.window.getDbView().getSelectedColumn() == 9) || (this.window.getDbView().getSelectedColumn() == 10)) {
					this.window.controller.saveEntry();
				}
			} catch (IndexOutOfBoundsException e1) {

			}
		}
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

}
